<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>按钮改变css</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .outer {
            width: 350px;
            margin: 10px auto;
        }

        input {
            padding: 3px;
            font-family: inherit;
            border: 1px solid #ccc;
        }

        p {
            margin: 10px;
        }

        label {
            text-align: right;
            width: 5em;
            display: inline-block;
        }

        button {
            cursor: pointer;
            margin: 0 5px;
        }

        #show {
            color: #fff;
            width: 180px;
            height: 180px;
            background: #000;
            margin: 0 auto;
            padding: 10px;
            font: 12px/1.5 Tahoma;
        }
    </style>
    <script>
        window.onload = function(){
            var oBtn = document.getElementsByTagName("button");
            var oInput = document.getElementsByTagName("input");
            var oDiv1 = document.getElementById("show");

            oBtn[0].onclick = function(){
                oDiv1.style[oInput[0].value] = oInput[1].value;
                console.log(oInput[0].value + oInput[1].value);
            }

            oBtn[1].onclick = function(){
                oDiv1.removeAttribute("style");
            }
        }
    </script>
</head>

<body>
    <div class="outer">
        <p>
            <label for="">属性名：</label>
            <input type="text" value="background">
        </p>
        <p>
            <label for="">属性值：</label>
            <input type="text" value="blue">
        </p>
        <p>
            <label for=""></label>
            <button>确定</button>
            <button>重置</button>
        </p>
    </div>
    <div id="show">
        在上方输入框输入"属性名"及"属性值"，点击确定按钮查看效果。
    </div>
</body>

</html>